package com.qf.service.impl;

import com.qf.mapper.StageMapper;
import com.qf.model.Stage;
import com.qf.page.PageResult;
import com.qf.page.QueryPageBean;
import com.qf.service.StageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StageServiceImpl implements StageService {
    @Autowired
    private StageMapper stageMapper;

    @Override
    public List<Stage> getAll() {
        List<Stage> list =stageMapper.selectAll();
        return list;
    }

    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        PageResult pageResult = new PageResult();
        Integer currentPage = queryPageBean.getCurrentPage(); //当前页
        Integer pageSize = queryPageBean.getPageSize();//每页大小
        //total 总记录数
        List<Stage> page = stageMapper.findPage((currentPage - 1) * pageSize, pageSize);
        //rows  当前页的数据
        Long count = stageMapper.count();
        pageResult.setRows(page);
        pageResult.setTotal(count);
        return pageResult;
    }


}
